package com.adtech.adms.commons.file.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 附件组
 * 
 * @author Dormin
 * @since 2012-8-11
 * 
 * @copyright 2012 天大求实电力新技术股份有限公司 版权所有
 */
public class FileGroup implements Serializable {

	private static final long serialVersionUID = -1385656039360271609L;
	
	private String id;
	private String name;
	private List<FileInfo> files = new ArrayList<FileInfo>();
	
	public FileGroup(){
		
	}
	
	public FileGroup(String name){
		this.name = name;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<FileInfo> getFiles() {
		return files;
	}

	public void setFiles(List<FileInfo> files) {
		this.files = files;
	}
	
	public void addFile(FileInfo file) {
		if (file != null){
			if(file.getGroup()!=null && file.getGroup().getFiles()!=null) {
				file.getGroup().getFiles().remove(file);
			}
			file.setGroup(this);
			this.getFiles().add(file);
		}
	}
	
	public void addFiles(List<FileInfo> files) {
		if (files != null) {
			for (FileInfo file : files){
				addFile(file);
			}
		}
	}
	
}
